<?php
include '../include/common.inc.php';
$adminhelp=new Adminhelp();
if(!$q=$adminhelp->mcheckol()){
    header("Location:".$C['SITE_URL']."/admin/login.php");
    exit;
}
$adminhelp->mupdatesession();
unset($q);
$newtime=time();
if(!$action){
    if($submit){
        if($id){
            if($chk){
                foreach($chk as $v){
                    $db->query("delete from lunbo where id={$v}");
                }
                $id=array_diff($id,$chk);
            }
            
            
            foreach ($id as $v){
                $db->query("update lunbo set src='{$src[$v]}',href='{$href[$v]}',des='{$des[$v]}',time={$time[$v]} where id = {$v}");
            }
             
             
        }
        if($newid){
            foreach($newid as $k=>$v){
                if($newsrc[$k]!="" && $newhref[$k]!=""&&$newdes[$k]!=""){
                    $db->query("insert into lunbo (src,href,des,time) values ('{$newsrc[$k]}','{$newhref[$k]}','{$newdes[$k]}','{$newtime}')");
                }
            }
        }
    }
    $q=$db->query("select * from lunbo order by time desc");
    $arr=array();
    while($row=$db->fetch_array($q)){
        $arr[]=$row;
    }
    unset($q);
    $tpl->assign("list",$arr);
    
    
    $tpl->display("admin/mlunbo.html");
}
